<extend name="Public/base"/>

<block name="body">
	 <div class="am-container">
		 <div class="submenu clear">

			 <a class="submenu-item <eq name="sort" value="create_time">active</eq>" href="{:U('Goods/cate',array('id'=>$cate['id'],'type'=>$type))}">默认</a><span>|</span>
			 <a class="submenu-item <eq name="sort" value="volume">active</eq>"  href="{:U('Goods/cate',array('id'=>$cate['id'],'sort'=>'volume','type'=>$type))}">销量</a><span>|</span>
			 <a class="submenu-item <eq name="sort" value="price">active</eq>"  href="{:U('Goods/cate',array('id'=>$cate['id'],'sort'=>'price','type'=>$type))}">价格</a><span>|</span>
			 <a class="submenu-item <eq name="sort" value="hits">active</eq>"  href="{:U('Goods/cate',array('id'=>$cate['id'],'sort'=>'hits','type'=>$type))}">浏览量</a>

		 </div>
		 <div class="goods-list clear">

			<volist name='goods' id='vo'>
				<div class="item">
					<div class="goods-pic">
						<a target="_blank" class="pic-img" href="{:U('/pointsmall/'.$vo['id'])}">
							<img class="lazy am-img-responsive" data-original="{$vo.pic_url|get_image_url}" src="__IMG__/loading.jpg" alt="{$vo.name}" style="display: inline;">
						</a>
					</div>

					<p class="title">
						<a target="_blank" class="black" href="{:U('/pointsmall/'.$vo['id'])}">{$vo.name}</a>
					</p>
					<div class="goods-price">
						所需积分：<b class="price">
							{$vo['price']|number_format=0}
						</b>

					</div>
					<div class="keyword">

					</div>
				</div>
			</volist>

	 	</div>
	 	
	 	<notempty name="_page">
			<div class="am-g">
				<ul class="am-pagination">{$_page}
    	 		</ul>
				<button id="next" class="am-btn am-btn-block am-btn-primary" p="2" total-page="{$total_page}">
					点击加载更多
				</button>
			</div>
   		 </notempty>
      </div>	 
</block>
<block name="script">
<script>
	$(function(){
		$('.goods-list').find('li').each(function(){

			a = $('.goods-list').innerWidth()/4*1.5;
			b = $('.goods-list').innerWidth()/4*0.95;
			$(this).find('.goods-pic').each(function(){
				$(this).innerHeight(Math.round(b)-1);	
			});
			$(this).innerHeight(Math.round(a)-1);	
			
		});
		$('#next').click(function(){
		  	LoadPage();  
		  });
	});
	function LoadPage(){
		var currentPage = $('#next').attr('p') ? $('#next').attr('p') : 1;
		$.get("{:U('PointsMall/index')}",{p:currentPage},function(result){
			if(result.errno==0){
				$('.goods-list').append(result.content);
				$('#next').attr('p',result.p);
				if(result.p>$('#next').attr('total-page')){
					$('#next').html('木有了，亲');
					$('#next').attr('disabled',true);
					$('#next').addClass('disabled');
				}
			}
		},'json');	
	}
</script>
</block>
